package ar.edu.uba.fi.jmit.sender.impl.common;

import java.util.HashMap;
import java.util.Map;

import ar.edu.uba.fi.jmit.sender.exception.SenderException;

public class DestinationInfoResgistry {

	private static Map<String, Map<String, String>> destinations;
	
	public static void addDestination(String destinationName, Map<String, String> properties) {
		if(destinations == null) {
			destinations = new HashMap<String, Map<String,String>>();
		}
		destinations.put(destinationName, properties);
	}
	
	public static Map<String, String> getDestination(String destinationName) throws SenderException {
		if(destinations == null || destinations.isEmpty()) {
			throw new SenderException("The DestinationInfoRegistry is empty! there is no destination info for name " + destinationName);
		}
		if(!destinations.containsKey(destinationName)) {
			throw new SenderException("The DestinationInfoRegistry does not contains destination info for name " + destinationName);
		}
		return destinations.get(destinationName);
	}
	
}
